import Vue from 'vue'
import Vuex from 'vuex'
import header from '@/store/headers/headers.js'
import title from '@/store/headers/title.js'
import detaList from './dataList/datalist'
import shopCar from './shopCar/shop'
Vue.use(Vuex)
export default new Vuex.Store({
  state: {
    token: sessionStorage.getItem('token') || ''
  },
  actions: {
    setToken({ commit }, token) {
      // 存储token到sessionStorage中
      sessionStorage.setItem('token', token)
      commit('setToken', token)
    },
    setValue({ commit }, token){
      commit('setValue', token)
      
    }
  },
  mutations: {
    setToken(state, token) {
      state.token = token
    },
    setValue(state,token){
      state.token = ''
    }
  },
  modules: {
    header,
    title,
    detaList,
    shopCar
  }
})
